package com.ruoyi.project.treat.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.treat.domain.TrePatient;
import com.ruoyi.project.treat.service.ITrePatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/treat/patient")
public class TrePatientController  extends BaseController {
    @Autowired
    private ITrePatientService iTrePatientService;

    @GetMapping("/{patiCode}")
    @PreAuthorize("@ss.hasPermi('treat:register:index')")
    public AjaxResult findPatient(@PathVariable String patiCode){
        TrePatient patient = iTrePatientService.findPatient(patiCode);
        return AjaxResult.success(patient);
    }


    public  TableDataInfo findPatientList(TrePatient trePatient) {
        startPage();
        List<TrePatient> patientList = iTrePatientService.findPatientList(trePatient);
        return getDataTable(patientList);
    }
}
